﻿using System.Collections.Generic;
using System.Threading;
using System.Xml.Linq;

namespace DllShepherd.SilverlightGoogleMaps.Web.Resources
{
	public class StringsResourceName { public const string Name = "StringsResource"; }
	[global::System.CodeDom.Compiler.GeneratedCodeAttribute("T4resx.tt", "1.1.0.0")]
	public class StringsResource
	{
		public static void SetResourceDictionary(XElement xml)
		{
		    _useResourceManager = false;
		    _resourcesDictionary = new Dictionary<string, string>();
		    foreach (var data in xml.Descendants("data"))
		    {
		        _resourcesDictionary.Add(data.Attribute("name").Value, data.Element("value").Value);
		    }
		}

		private static bool _useResourceManager = true;
        private static Dictionary<string, string> _resourcesDictionary;
        protected static global::System.Resources.ResourceManager resourceMan;
        
        /// <summary>
        ///   Returns the cached ResourceManager instance used by this class.
        /// </summary>
        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
        protected static global::System.Resources.ResourceManager ResourceManager 
		{
            get 
			{
                if (object.ReferenceEquals(resourceMan, null)) 
				{
                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DllShepherd.SilverlightGoogleMaps.Web.Resources.StringsResource", typeof(StringsResource).Assembly);
                    resourceMan = temp;
                }
                return resourceMan;
            }
        }
        
        /// <summary>
        ///   Returns the formatted resource string.
        /// </summary>
        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
        private static string GetResourceString(string key, params string[] tokens)
		{
            if(!_useResourceManager)
            {
                if (_resourcesDictionary.ContainsKey(key))
                    return _resourcesDictionary[key];
                return string.Empty;
            }
			var culture = Thread.CurrentThread.CurrentCulture;
            var str = ResourceManager.GetString(key, culture);

			for(int i = 0; i < tokens.Length; i += 2)
				str = str.Replace(tokens[i], tokens[i+1]);
										
            return str;
        }
        
		
		public static string StreetView { get { return GetResourceString(Names.StreetView); } }

		public static class Names
		{
			public const string StreetView = "StreetView";
		}
	}
}
